package com.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blog.pojo.Tag;
import com.blog.service.TagService;
import com.blog.mapper.TagMapper;
import org.springframework.stereotype.Service;

/**
* @author DELL
* @description 针对表【t_tag】的数据库操作Service实现
* @createDate 2022-07-10 15:20:14
*/
@Service
public class TagServiceImpl extends ServiceImpl<TagMapper, Tag>
    implements TagService{

    @Override
    public Page<Tag> page(int page, int pageSize, String bolgTagContent,Long typeId) {
        //构造分页对象
        Page<Tag> tagPage = new Page<>(page, pageSize);
        //条件构造
        LambdaQueryWrapper<Tag> tagLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //添加过滤条件
        tagLambdaQueryWrapper.like(bolgTagContent!=null,Tag::getBlogTagContent,bolgTagContent);
        tagLambdaQueryWrapper.like(typeId!=null,Tag::getTypeId,typeId);
        //排序条件：按修改日期,降序
        tagLambdaQueryWrapper.orderByDesc(Tag::getUpdateTime);
        //执行分页查询
        return this.page(tagPage,tagLambdaQueryWrapper);
    }
}




